<?xml version="1.0" encoding="utf-8"?>
<!--
	XML Schema for NQCS menu and toolbar definitions.
	Specification revision: 1.03
	
	Copyright (c) 2007-2012 Andreas Weizel.
	http://www.awzhome.de/
	
	This file is subject to Mozilla Public License 1.1.
-->
<xs:schema targetNamespace="http://www.awzhome.de/xmlns/nqcs/bardef/1.0" elementFormDefault="qualified" xmlns="http://www.awzhome.de/xmlns/nqcs/bardef/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">

	<!-- The root element-->
	<xs:element name="NQMenuDefinition">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="menubandref" type="menubandrefType" minOccurs="0" maxOccurs="1" />
				<xs:group ref="menurootGroup" minOccurs="0" maxOccurs="unbounded" />
			</xs:sequence>
			<xs:attribute name="version" type="xs:string" />
		</xs:complexType>
	</xs:element>

	<!-- Data types -->
	<xs:simpleType name="resDef">
		<xs:restriction base="xs:string">
			<xs:pattern value="(\{\w*\}).*" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="bandtypeDef">
		<xs:restriction base="xs:string">
			<xs:enumeration value="toolband" />
			<xs:enumeration value="contextmenu" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="itemtypeDef">
		<xs:restriction base="xs:string">
			<xs:enumeration value="button" />
			<xs:enumeration value="checkbox" />
			<xs:enumeration value="radiobutton" />
			<xs:enumeration value="dropdown" />
			<xs:enumeration value="splitbutton" />
			<xs:enumeration value="menuitem" />
			<xs:enumeration value="label" />
			<xs:enumeration value="combobox" />
			<xs:enumeration value="textbox" />
			<xs:enumeration value="separator" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="conditionObjectDef">
		<xs:restriction base="xs:string">
			<xs:enumeration value="session" />
			<xs:enumeration value="view" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="conditionVisibilityDef">
		<xs:restriction base="xs:string">
			<xs:enumeration value="show" />
			<xs:enumeration value="enable" />
		</xs:restriction>
	</xs:simpleType>

	<!-- Groups -->
	<xs:group name="menurootGroup">
		<xs:choice>
			<xs:element name="baritemref" type="baritemrefType" />
			<xs:element name="bandref" type="bandrefType" />
			<xs:element name="baritem" type="baritemType" />
			<xs:element name="band" type="bandType" />
		</xs:choice>
	</xs:group>

	<!-- Band types -->
	<xs:complexType name="bandrefType">
		<xs:sequence>
			<xs:element name="baritem" type="baritemType" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="condition" type="conditionType" minOccurs="0" maxOccurs="unbounded" />
		</xs:sequence>
		<xs:attribute name="key" type="xs:string" use="required" />
	</xs:complexType>

	<xs:complexType name="menubandrefType">
		<xs:sequence>
			<xs:element name="baritem" type="baritemType" minOccurs="0" maxOccurs="unbounded" />
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="bandType">
		<xs:complexContent>
			<xs:extension base="bandrefType">
				<xs:attribute name="type" type="bandtypeDef" use="required" />
				<xs:attribute name="grip" type="xs:boolean" use="optional" />
				<xs:attribute name="text" type="xs:string" use="optional" />
				<xs:attribute name="textres" type="resDef" use="optional" />
				<xs:attribute name="overflowbutton" type="xs:boolean" use="optional" />
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>

	<!-- Bar item types -->
	<xs:complexType name="baritemrefType">
		<xs:sequence>
			<xs:element name="baritem" type="baritemType" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="condition" type="conditionType" minOccurs="0" maxOccurs="unbounded" />
		</xs:sequence>
		<xs:attribute name="key" type="xs:string" use="required" />
	</xs:complexType>

	<xs:complexType name="baritemType">
		<xs:complexContent>
			<xs:extension base="baritemrefType">
				<xs:attribute name="text" type="xs:string" use="optional" />
				<xs:attribute name="textres" type="resDef" use="optional" />
				<xs:attribute name="tooltip" type="xs:string" use="optional" />
				<xs:attribute name="tooltipres" type="resDef" use="optional" />
				<xs:attribute name="showimage" type="xs:boolean" use="optional" />
				<xs:attribute name="showtext" type="xs:boolean" use="optional" />
				<xs:attribute name="imageres" type="resDef" use="optional" />
				<xs:attribute name="type" type="itemtypeDef" use="required" />
				<xs:attribute name="enabled" type="xs:boolean" use="optional" />
				<xs:attribute name="visible" type="xs:boolean" use="optional" />
				<xs:attribute name="rightalign" type="xs:boolean" use="optional" />
				<xs:attribute name="shortcutkeys" type="xs:string" use="optional" />
				<xs:attribute name="previousitem" type="xs:string" use="optional" />
				<xs:attribute name="nextitem" type="xs:string" use="optional" />
				<xs:attribute name="size" type="xs:double" use="optional" />
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>

	<!-- Other types -->
	<xs:complexType name="conditionType">
		<xs:attribute name="name" type="xs:string" use="required" />
		<xs:attribute name="type" type="conditionObjectDef" use="required" />
		<xs:attribute name="action" type="conditionVisibilityDef" use="required" />
	</xs:complexType>
</xs:schema>